<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue-2.2.1.js"></script>

    <script src="vue-router-2.3.1.js"></script>
</head>
<body>
    
    <div id="app">
        <router-link to="/login">登入</router-link>
        <router-link to="/register">注册</router-link>
        
        <router-view></router-view>
    </div>
</body>

    <script>
    
    var account = Vue.extend({
        template:'<div><h1>组件对象</h1><router-view></router-view></div>'
    });

    var login = Vue.extend({
        template:'<div><h1>登入</h1></div>'
    });

    var register = Vue.extend({
        template:'<div><h1>注册</h1></div>'
    });

    var router  = new VueRouter({
        routes:[
            {
                path:'/account',
                component:account,
                children:[
                    {
                        path:'/',
                        component:login,
                    },
                    {
                        path:'/login',
                        component:login,

                    },
                    {
                        path:'/register',
                        component:register,
                    }
                ]
            },
        ],
    });

    var vm = new Vue({
        el:'#app',
        router:router
    })
        
    </script>
</html>